home *** CD-ROM | disk | FTP | other *** search
Wrap
10 ' ********************************************************************** 20 ' ** MOIRE.BAS ** 30 ' ** Adapted From: Listing 3, Getting Moire From Your Computer. ** 40 ' ** February, 1984 ** 50 ' ** Creative Computing - Mark Gardner ** 60 ' ** This Version: Michael L. Connell ** 70 ' ** 3050 1/2 East, 2225 South ** 80 ' ** Salt Lake City, Utah 84109 ** 90 '********************************************************************** 100 CLS:KEY OFF:LOCATE 10,35:PRINT"More Moire:":LOCATE 11,24:PRINT"A program for pattern generation.":LOCATE 12,14:PRINT"Do you want background information and instructions?" 110 A$=INKEY$:IF A$="" THEN 110 120 IF A$ <>"n" AND A$ <> "N" AND A$<>"y" AND A$<>"Y" THEN 110 130 IF A$ ="n" OR A$ = "N" THEN 160 140 GOSUB 1210 150 '********* INPUT OF PARAMETERS FOR PATTERN GENERATION ********* 160 CLS:INPUT"Enter a number from 1 to 39: ";O1:INPUT"Enter a number from 1 to 30: ";O2 170 PRINT:PRINT"Select one:":PRINT" 1 - X*X and Y*Y":PRINT" 2 - X*Y and Y*Y":PRINT" 3 - X*Y and Y*X":PRINT" 4 - X*X and Y*X" 180 A$=INKEY$:IF A$="" THEN 180 190 IF A$ <> "1" AND A$ <> "2" AND A$<>"3" AND A$<>"4" THEN 180 200 PRINT"You have selected ";A$;"." 210 PRINT:PRINT"Select one:":PRINT" 1 - O1 and O1":PRINT" 2 - O1 and O2" 220 G$=INKEY$:IF G$="" THEN 220 230 IF G$ <> "1" AND G$ <> "2" THEN 220 240 PRINT"You have selected ";G$;"." 250 PRINT:PRINT"Select equation type:":PRINT" 1 - Square Root":PRINT" 2 - Sin":PRINT" 3 - Cos" 260 X$=INKEY$:IF X$="" THEN 260 270 IF X$ <> "1" AND X$ <> "2" AND X$<>"3" THEN 260 280 PRINT"You have selected ";X$;"." 290 '********* THIS PAUSE IS SO THAT THE PARMS MAY BE RECORDED ********* 300 '********* I USE THE NOTEPAD FROM SIDEKICK WHICH DOES WELL ********* 310 PRINT"Press <SPACE> to continue.." 320 B$=INKEY$:IF B$<>" " THEN 320 330 '********* SET UP COUNTER SO PROGRESS MAY BE MONITORED ********* 340 CLS:LOCATE 9,32:PRINT"I";:LOCATE 9,37:PRINT"J";:LOCATE 10,31:PRINT"62"; 350 LOCATE 8,19:PRINT"Countdown to Pattern Completion":LOCATE 20,1 360 '********* GENERATE PATTERN ACCORDING TO THE PARMS SELECTED ********* 370 DIM PRINTARRAY(79,63) 380 DATA 12,62,17,84,21,85,25,23,28,21,30,9,33,38,35,68,37,85,39,89 390 B=10 400 FOR I=1 TO 62:FOR J=1 TO 78 410 IF G$="2" THEN GOTO 440 420 XC1=J-O1+B:YC1=I-O2 430 XC2=J-O2:YC2=I-O1-B:GOTO 460 440 XC1=J-O1+B:YC1=I-O2 450 XC2=J-O1:YC2=I-O2-B 460 YC1=YC1*1.6666:YC2=YC2*1.6666 470 IF X$="2" OR X$="3" THEN GOSUB 1560:GOTO 560 480 IF A$="2" THEN 520 490 IF A$="3" THEN 530 500 IF A$="4" THEN 540 510 RC1=SQR(XC1*XC1+YC1*YC1):RC2=SQR(XC2*XC2+YC2*YC2):GOTO 550 520 RC1=SQR(ABS(XC1*YC1+YC1*YC1)):RC2=SQR(ABS(XC2*XC2+YC2*YC2)):GOTO 550 530 RC1=SQR(ABS(XC1*YC1+XC1*YC1)):RC2=SQR(ABS(RC2*XC2+YC2*YC2)):GOTO 550 540 RC1=SQR(ABS(XC1*XC1+XC1*YC1)):RC2=SQR(ABS(XC2*XC2+YC2*YC2)) 550 RESTORE 560 FOR K = 1 TO 10 570 READ RNEXT 580 IF RNEXT<RC1 THEN 620 590 IF K MOD 2 = 1 THEN INSERT = 1 ELSE INSERT = 4 600 PRINTARRAY(J,I)=INSERT 610 K=11 620 NEXT K 630 RESTORE 640 FOR K = 1 TO 10 650 READ RNEXT 660 IF RNEXT<RC2 THEN 700 670 IF K MOD 2 = 1 THEN INSERT=2 ELSE INSERT=8 680 PRINTARRAY(J,I)=PRINTARRAY(J,I)+INSERT 690 K=11 700 NEXT K 710 LOCATE 10,35:PRINT 78-J:NEXT J:LOCATE 10,30:PRINT 62-I:NEXT I 720 '********* ALERT USER THAT PATTERN IS READY TO DISPLAY ********* 730 BEEP:BEEP:BEEP 740 '********* WAIT UNTIL READY ********* 750 PRINT"Ready to display pattern?" 760 P$=INKEY$:IF P$<>"Y" AND P$<>"y" THEN 760 770 '******** DISPLAY PATTERN ON CRT ********* 780 FOR I=0 TO 63 790 FOR J=1 TO 78 800 AR=PRINTARRAY(J,I) 810 IF AR=0 THEN PRINT" ";:GOTO 910 820 IF AR=4 THEN PRINT" ";:GOTO 910 830 IF AR=8 THEN PRINT" ";:GOTO 910 840 IF AR=3 THEN PRINT"H";:GOTO 910 850 IF AR=12 THEN PRINT"H";:GOTO 910 860 IF AR+PRINTARRAY(J+1,I)=3 THEN PRINT "]";:GOTO 910 870 IF AR+PRINTARRAY(J-1,I)=3 THEN PRINT "[";:GOTO 910 880 IF AR+PRINTARRAY(J+1,I)=12 THEN PRINT "]";:GOTO 910 890 IF AR+PRINTARRAY(J-1,I)=12 THEN PRINT "[";:GOTO 910 900 PRINT "."; 910 NEXT J 920 PRINT 930 NEXT I 940 '********* CHECK FOR HARDOCOPY REQUESTS ********* 950 PRINT"Do you want hardcopy of this pattern?" 960 H$=INKEY$:IF H$="" THEN 960 970 '********* CHECK FOR RUNNING OF PROGRAM AGAIN ********* 980 IF H$="y" OR H$="Y" THEN GOSUB 1040 990 PRINT"Try again?" 1000 C$=INKEY$:IF C$="" THEN 1000 1010 IF C$="y" OR C$="Y" THEN RUN 1020 CLS:PRINT"I hope that this program has brought you some enjoyment.":END 1030 '********** HARDCORY SUBROUTINE ******** 1040 FOR I=0 TO 63 1050 FOR J=1 TO 78 1060 AR=PRINTARRAY(J,I) 1070 IF AR=0 THEN LPRINT" ";:GOTO 1170 1080 IF AR=4 THEN LPRINT" ";:GOTO 1170 1090 IF AR=8 THEN LPRINT" ";:GOTO 1170 1100 IF AR=3 THEN LPRINT"H";:GOTO 1170 1110 IF AR=12 THEN LPRINT"H";:GOTO 1170 1120 IF AR+PRINTARRAY(J+1,I)=3 THEN LPRINT "]";:GOTO 1170 1130 IF AR+PRINTARRAY(J-1,I)=3 THEN LPRINT "[";:GOTO 1170 1140 IF AR+PRINTARRAY(J+1,I)=12 THEN LPRINT "]";:GOTO 1170 1150 IF AR+PRINTARRAY(J-1,I)=12 THEN LPRINT "[";:GOTO 1170 1160 LPRINT "."; 1170 NEXT J 1180 LPRINT 1190 NEXT I:RETURN 1200 '********* INSTRUCTIONS SUBROUTINE ******** 1210 CLS 1220 LOCATE 5,35:PRINT"More Moire.":LOCATE 8,1 1230 PRINT" In the February, 1984 edition of Creative Computing Mark Gardner " 1240 PRINT"presented a short program for generating moire patterns which could be used" 1250 PRINT"without either a graphics printer, or graphics commands. I experimented " 1260 PRINT"with utilizing different input types and soon found that in addition to the" 1270 PRINT"creation of moire patterns I could make many other different designs quite " 1280 PRINT"simply." 1290 PRINT 1300 PRINT 1310 PRINT" This program began as a user interface to make the selection of " 1320 PRINT"parameters easier. It developed into non-moire pattern types, and allows " 1330 PRINT"flexibility in display. " 1340 PRINT:PRINT:PRINT"Press any key to continue...." 1350 A$=INKEY$:IF A$="" THEN 1350 1360 CLS:LOCATE 5,35:PRINT"More Moire.":LOCATE 8,1 1370 PRINT" The user is requested to enter parameters which effect the pattern " 1380 PRINT"being generated. The first of these, O1 and O2, are used to determine the " 1390 PRINT"offset from the center. The user is then given the oportunity to select " 1400 PRINT"various options dealing with the equations used to generate the pattern. " 1410 PRINT 1420 PRINT 1430 PRINT" The pattern is then generated according to the determined options. " " 1440 PRINT"Once generated the user is prompted and the pattern may be displayed. " 1450 PRINT"Display is first to the CRT and then to the printer, if desired. With " 1460 PRINT"experience many interesting and pleasing designs may be created. " 1470 PRINT" 1480 PRINT 1490 PRINT 1500 PRINT" The program is slow, so be warned, listen for the bell, and enjoy!! " 1510 PRINT" Press any key to begin. {<ESC> will exit the program at this point.}" 1520 A$=INKEY$:IF A$="" THEN 1520 1530 IF A$=CHR$(27) THEN CLS:PRINT"Sorry you didn't try the program, maybe another time!":PRINT:PRINT:PRINT:END 1540 RETURN 1550 '********* Sin and Cosine Equation Options ********* 1560 IF X$="3" GOTO 1650 1570 IF A$="2" THEN 1610 1580 IF A$="3" THEN 1620 1590 IF A$="4" THEN 1630 1600 RC1=10*SIN(XC1*XC1+YC1*YC1):RC2=10*SIN(XC2*XC2+YC2*YC2):GOTO 1640 1610 RC1=10*SIN(ABS(XC1*YC1+YC1*YC1)):RC2=10*SIN(ABS(XC2*XC2+YC2*YC2)):GOTO 1640 1620 RC1=10*SIN(ABS(XC1*YC1+XC1*YC1)):RC2=10*SIN(ABS(RC2*XC2+YC2*YC2)):GOTO 1640 1630 RC1=10*SIN(ABS(XC1*XC1+XC1*YC1)):RC2=10*SIN(ABS(XC2*XC2+YC2*YC2)) 1640 RESTORE :RETURN 1650 IF A$="2" THEN 1690 1660 IF A$="3" THEN 1700 1670 IF A$="4" THEN 1710 1680 RC1=10*COS(XC1*XC1+YC1*YC1):RC2=10*COS(XC2*XC2+YC2*YC2):GOTO 1720 1690 RC1=10*COS(ABS(XC1*YC1+YC1*YC1)):RC2=10*COS(ABS(XC2*XC2+YC2*YC2)):GOTO 1720 1700 RC1=10*COS(ABS(XC1*YC1+XC1*YC1)):RC2=10*COS(ABS(RC2*XC2+YC2*YC2)):GOTO 1720 1710 RC1=16*COS(ABS(XC1*XC1+XC1*YC1)):RC2=16*COS(ABS(XC2*XC2+YC2*YC2)) 1720 RESTORE :RETURN